<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticleTables extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('articles', function(Blueprint $table){
			$table->increments('id');
			$table->smallInteger('class');
			$table->smallInteger('law_cat');
			$table->integer('down_group')->nullable();
			$table->string('class_tree', 50)->defaults()->nullable();
			$table->string('img', 100)->defaults()->nullable(); // 缩略图
			$table->string('keys', 100)->defaults()->nullable(); // 关键字
			$table->string('title', 100);//标题			
			$table->string('info', 200);//简介	
			$table->string('file_path', 100)->defaults()->nullable();// 下载文件路径
			$table->integer('hits')->nullable()->defaults(0);//点击数		
			$table->integer('comments')->nullable()->defaults(0);//评论数		
			$table->integer('likes')->defaults(0)->nullable();//点赞数
			$table->integer('downs')->defaults(0)->nullable();//下载数
			$table->smallInteger('orders')->nullable()->defaults(0);//排序
			$table->integer('creator_id')->nullable();// 创建人	
			$table->string('last_ip', 20)->defaults()->nullable();// 客户ip
			$table->tinyInteger('status')->defaults(1)->nullable();// 文章状态
			$table->timestamps();
		});

		Schema::create('article_classs', function(Blueprint $table){
			$table->increments('id');
			$table->integer('parent_id')->defaults(0)->nullable();
			$table->tinyInteger('level')->defaults(0)->nullable();
			$table->string('tree', 50)->defaults()->nullable();
			$table->string('name', 20)->defaults()->nullable(); 
			$table->string('keys', 16)->defaults()->nullable(); 
			$table->smallInteger('orders')->nullable()->defaults(0);
			$table->integer('creator_id')->nullable();// 创建人	
			$table->tinyInteger('status')->defaults(1)->nullable();
			$table->timestamps();
		});

		Schema::create('article_infos', function(Blueprint $table){
			$table->integer('id')->primary();
            $table->text('content');
			$table->timestamps();
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('articles');
		Schema::drop('article_classs');
		Schema::drop('article_infos');
	}

}
